package com.itheima.Demo;

import java.io.*;
import java.util.TreeSet;

public class Demo练习 {
    public static void main(String[] args) throws IOException {
        //输入流
        //字符流
        BufferedReader br  = new BufferedReader(new FileReader("Day17codes\\aaa\\出师表.txt"));
        //创建一个集合,因为需要排序,所以创建treeset;
        TreeSet<String> set  = new TreeSet<>();
        //读取数据;
        String s;
        while ((s=br.readLine())!=null){
            set.add(s);
        }
        //关闭输入流
        br.close();
        //把集合中排好序字符串写会到文件中
        BufferedWriter bw = new BufferedWriter(new FileWriter("Day17codes\\aaa\\出师表01.txt"));
        //遍历集合
        for (String s1 : set) {
            bw.write(s1);
            bw.newLine();
        }
        bw.close();
    }
}

